#!usr/bin/env python
# -*- coding: utf-8 -*-
from ._base import BaseModel, db
from datetime import datetime


class Domain(BaseModel):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    domain_source_id = db.Column(db.Integer, index=True)
    is_relation = db.Column(db.SmallInteger, index=True, comment=u"是否是关联备案")
    name = db.Column(db.String(255), comment=u'主办单位（或个人）')  # 所属人
    category = db.Column(db.String(255), comment=u'类型（个人或企业）')  # 类型 个人 企业
    url = db.Column(db.String(100), comment=u'域名')  # 域名
    site_name = db.Column(db.String(100), comment=u'网站名称')  # 网站名称
    record_time = db.Column(db.String(100), comment=u'审核通过时间')  # 备案时间
    record_licence = db.Column(db.String(100), comment=u'备案许可证')  # 备案批次
    record_sn = db.Column(db.String(100), comment=u'备案号')  # 备案号
    created = db.Column(db.DATETIME, default=datetime.now, comment=u'创建时间')  # 存储时间
    limit_in = db.Column(db.String(100), comment=u'是否限制接入')  # 是否限制接入
    pre_examine = db.Column(db.String(100), comment=u'网站前置审批项')  # 是否限制接入


class DomainSource(BaseModel):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    domain = db.Column(db.String(255), index=True)
    platform = db.Column(db.SmallInteger, comment=u"1阿里云 2聚名")
    page = db.Column(db.Integer, comment=u"当前所在页数")
    spider_number = db.Column(db.String(255), index=True, comment=u"爬取编号")
    price = db.Column(db.String(255), comment=u"价格")
    amount = db.Column(db.DECIMAL(10, 2), comment=u"价格")
    register_date = db.Column(db.Date, comment=u"注册时间")
    expired_date = db.Column(db.Date, comment=u"过期时间")
    sale_end_date = db.Column(db.Date, comment=u"售卖截止时间")
    is_expired = db.Column(db.SmallInteger, comment=u"过期时间到了或者截止时间到了都将其设置为1", index=True)
    is_icp_check = db.Column(db.SmallInteger, comment=u"是否进行过ipc备案检查", index=True)
    is_beian = db.Column(db.SmallInteger, comment=u"是否备案", index=True)
    beian_category = db.Column(db.SmallInteger, comment=u"备案类型1企业2个人", index=True)
    is_hide = db.Column(db.SmallInteger, comment=u"是否隐藏", index=True)
    suffix = db.Column(db.String(32), comment=u"后缀", index=True)
    opera_status = db.Column(db.SmallInteger, comment=u"操作状态0默认1关注2买入3卖出4下架5观察", index=True)
    rand_no = db.Column(db.Integer, index=True, comment=u"随机编号，给分布式icp_check使用")
    remark = db.Column(db.Text)
    source_id = db.Column(db.String(100), comment=u"原始id")
    buy_url = db.Column(db.String(100), comment=u"购买链接")
    created = db.Column(db.DateTime)
    updated = db.Column(db.DateTime)
    is_join_ju_ming = db.Column(db.SmallInteger, comment=u"是否可入库聚名", index=True)
    not_join_reason = db.Column(db.Text, comment=u"不能入库原因")
    column_type = db.Column(db.Text, comment=u"栏目类型(1:一口价  2：竞价)")
    is_drop = db.Column(db.SmallInteger, comment=u"是否掉备案 1：是  2：否   其余为未备案")
    drop_date = db.Column(db.Date, comment=u"掉备案时间")
    delete_type = db.Column(db.String(200), comment=u"删除类型")
    is_publish = db.Column(db.SmallInteger, comment=u"是否发布  1： 是  2：否")
    icp = db.Column(db.String(100))
    tag = db.Column(db.SmallInteger, comment=u"标签")
    expected_price = db.Column(db.String(100), comment=u"预期价格")
    is_find_ali_same_domains = db.Column(db.SmallInteger, comment=u"是否寻找过阿里相似的域名  1： 是  2：否")


class DomainProperty(BaseModel):
    id = db.Column(db.Integer, primary_key=True, comment=u"非自增与DomainSource id 1对1")
    end_time = db.Column(db.DateTime, comment=u"竞价结束时间")
    is_wall = db.Column(db.SmallInteger, comment=u"是否被墙 1：是  2：否   其余为未备案")
    is_search_site_info = db.Column(db.SmallInteger, comment=u"是否筛查过网站信息 1：是  2：否   其余为未筛查")


class DomainSiteInfo(BaseModel):
    id = db.Column(db.Integer, primary_key=True, comment=u"非自增与DomainSource id 1对1")
    score = db.Column(db.Integer, comment=u"域名评分")
    age = db.Column(db.Integer, comment=u"历史年龄")
    uniformity = db.Column(db.String(200), comment=u"统一度")
    total_site = db.Column(db.Integer, comment=u"总建站")
    continue_age = db.Column(db.Integer, comment=u"最长连续建站时长")
    site_in_five_year = db.Column(db.Integer, comment=u"5年内建站总时长")
    site_continue_in_five_year = db.Column(db.Integer, comment=u"5年内建站最长连续时长")
    keywords_count = db.Column(db.Integer, comment=u"百度敏感词个数")
    keywords = db.Column(db.Text, comment=u"百度敏感词")
    has_site = db.Column(db.SmallInteger, comment=u"有无历史建站")
    has_employ_baidu = db.Column(db.SmallInteger, comment=u"有无百度收录")
    count_desc = db.Column(db.String(200), comment=u"收录描述")
    created = db.Column(db.DateTime)
    updated = db.Column(db.DateTime)


class DomainSiteRecord(BaseModel):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    domain_source_id = db.Column(db.Integer, comment=u"DomainSource id")
    category = db.Column(db.SmallInteger, comment=u"记录类型 1：建站历史  2：百度收录")
    title = db.Column(db.String(500), comment=u"标题")
    juzi_url = db.Column(db.String(500), comment=u"页面内容")
    employ_date = db.Column(db.String(200), comment=u"收录时间")
    created = db.Column(db.DateTime)
    updated = db.Column(db.DateTime)


class DomainPriceRecord(BaseModel):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    domain_source_id = db.Column(db.Integer, comment=u"DomainSource id")
    price = db.Column(db.String(255), comment=u"价格")
    created = db.Column(db.DateTime, default=datetime.now, comment=u"获取时间")


class DomainForAliSame(BaseModel):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    domain_source_id = db.Column(db.Integer, comment=u"DomainSource id")
    domain = db.Column(db.String(100), comment=u"相似域名")
    created = db.Column(db.DateTime, default=datetime.now)
